<?php

namespace XWAM\Addon\POrgUser\Controller;

/**
 * Description of UserAttrController
 *
 * @since 1.0 <2015-11-3> SoChishun <14507247@qq.com> Added.
 */
class UserAttrController extends AddonbaseController {

    function attr_list($type_id = 0) {
        $list = AddonD('UserAttr')->where(array('type_id' => $type_id))->select();
        $this->assign('list', $list);
        $this->assign('type_id',$type_id);
        $this->display_cpp();
    }

    function attr_edit($id = 0, $type_id = 0) {
        if ($id) {
            $data = AddonD('UserAttr')->find($id);
        } else {
            $data['type_id'] = $type_id;
        }
        $this->assign('data', $data);
        $this->display();
    }

    function attr_edit_save() {
        $result = AddonD('UserAttr')->save_type();
        $this->dialogJump($result['status'], $result['info']);
    }

    function change_status($id, $status) {
        $this->ajaxReturn(AddonD('UserAttr')->change_status($id, $status));
    }

    function change_sort($id, $sort) {
        $this->ajaxReturn(AddonD('UserAttr')->change_sort($id, $sort));
    }

    function attr_delete($id = '') {
        $this->ajaxReturn(AddonD('UserAttr')->delete_attr($id));
    }

}
